<script>
import {defineComponent} from 'vue'
import dateUtil from "@/utils/dateUtil";

export default defineComponent({
  name: "ActStatus",
  props: {
    act: Object,
    user: Object,
    apply: {
      type: Object,
      default: null
    }
  },
  computed: {
    timeStatus(){
      let i = dateUtil.cmpCurrentDateStr(this.act.startTime, this.act.endTime)
      switch (i){
        case -1:
          return '未开始'
        case 0:
          return '进行中'
        case 1:
          return '已结束'
        default:
          return ''
      }
    }
  }
})
</script>

<template>
  <div class="act-status-div">
    <template v-if="act.publish">
      <van-tag type="primary" size="medium" v-show="user.self">已发布</van-tag>
      <van-tag size="medium" color="#ffe1e1" text-color="#ad0000" v-show="timeStatus !== ''">{{timeStatus}}</van-tag>
    </template>
    
    <van-tag type="warning" size="medium" v-else v-show="user.self">未发布</van-tag>
    <template v-if="apply !== null">
      <van-tag type="success" size="medium">已报名</van-tag>
      <van-tag type="success" size="medium" v-show="apply.sign">已签到</van-tag>
    </template>
    
    
  </div>
</template>

<style scoped>
.act-status-div {
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>